package xc.com.course.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xc.com.common.Result;
import xc.com.course.domain.CourseMarket;
import xc.com.course.service.CourseMarketService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhuolizhong
 * @since 2021-06-03
 */
@RestController
@RequestMapping("/course-market")
@Api(tags = "courseMarket接口",description = "课程营销信息的增删改查")
@CrossOrigin
public class CourseMarketController {
    @Autowired
    private CourseMarketService courseMarketService;

    /**
     * 添加课程营销
     * @param courseMarket
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("根据课程id添加课程营销信息")
    public Result addCourseMarket(@RequestBody CourseMarket courseMarket){
        Result result = courseMarketService.addCourseMarket(courseMarket);
        return  result;
    }

    /**
     * 修改课程营销信息
     * @param courseMarket
     * @return
     */
    @PutMapping("/update")
    @ApiOperation("根据课程id修改课程营销信息")
    public Result updateById(@RequestBody CourseMarket courseMarket){
        Result result = courseMarketService.updateCourseMarket(courseMarket);
        return result;
    }
    @GetMapping("/selectByCourseId/{courseId}")
    @ApiOperation("根据课程id查询课程营销信息")
    public CourseMarket selectByCourseId(@PathVariable("courseId") String courseId){
        return courseMarketService.selectByCourseId(courseId);
    }
}

